//
//  AllCourse.swift
//  ddx0513
//
//  Created by jiang yongbin on 15/5/31.
//  Copyright (c) 2015年 jiang yongbin. All rights reserved.
//

import UIKit
import CoreData



/*
class Container: NSManagedObject {

@NSManaged var courseName: String
@NSManaged var numOfPeople: NSNumber
@NSManaged var lineImage: String
@NSManaged var courseImage : String
@NSManaged var starImage: String
@NSManaged var nameEng: String
@NSManaged var count: Int

}
*/


class AllCourse: UIViewController ,UITableViewDelegate,UITableViewDataSource {

    
    //@IBOutlet var tableView : UITableView!
    //容器详细
    var allcoursedetail:AllCourseDetail!
    
    var dataArr = NSMutableArray()
    
    override func viewDidLoad()
    {
       
        
         NSLog("view\(self.navigationController)string")
        
        super.viewDidLoad()
        //allcoursedetail = self.childViewControllers as! AllCourseDetail
        
       for (var i = 0;i < 10; i++ )
        {
            //dataArr.courseName = "计算机网络"
           // dataArr.numOfPeople = 888
           // dataArr.courseImage = UIImage(named: "背景块.png")
            //dataArr.lineImage = UIImage(named: "line.png")
           // dataArr.starImage = UIImage(named: "五星.png")
            //dataArr.count = 10
            
            dataArr.addObject("low is \(i)")
        }
  //      tableView.delegate = self
      //  tableView.dataSource = self
        
        ///////////////
        
        /*
        var subMenu = CCSegmentedControl(items: ["最新","热门","价格","筛选"])
        subMenu.frame = CGRectMake(0, 50, 320, 30)
        //subMenu.selectedStainView = UIImageView(image:UIImage(named: "线2.png"))
        
        subMenu.backgroundColor = subMenu.colorWithHexString("#ffffff")
        subMenu.segmentTextColor = subMenu.colorWithHexString("#838383")
        subMenu.addTarget(self, action: Selector("subMenuvalueChanged:"), forControlEvents: UIControlEvents.ValueChanged )
        
        self.view.addSubview(subMenu)
*/
        
        
        
      //  tableView.separatorStyle = UITableViewCellSeparatorStyle.None
        

       //     tableView.selectRowAtIndexPath(NSIndexPath(forRow: 0, inSection: 0), animated: true, scrollPosition: UITableViewScrollPosition.Top)
        
        //add by puying 
        
    
      //  tableView.separatorStyle = UITableViewCellSeparatorStyle.None


        //end add
        

        // Do any additional setup after loading the view.
    }
    

    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    
    //告知窗口现在有多少个item需要添加
    func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int
    {

        return  1
    }
    
    //处理单个View的添加
    func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell
    {
        //let cellid = "my cell id"
        
        var tableCell :AllCourseItem = tableView.dequeueReusableCellWithIdentifier("allCourseItem") as! AllCourseItem
        
        var s = dataArr.objectAtIndex(indexPath.row) as? String
        
        tableCell.courseName.text = s
              //tableCell.courseName.text = "test1"ggg           // tableCell.coursename.text = "test1"

       // tableCell.thumb.image = UIImage(named: item.largePhoto)
        
        return tableCell
    }
    
    
    
    func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath)
    {
    
        
        
        allcoursedetail = UIStoryboard(name: "FirstPage", bundle: nil).instantiateViewControllerWithIdentifier("allCourseDetail") as! AllCourseDetail
        
      
        
        //  self.navigationController?.pushViewController(allCourseDetail, animated: true)
        
        //self.presentViewController(allcoursedetail, animated: true, completion: nil)

      //
        
        
        self.navigationController?.pushViewController(allcoursedetail, animated: true)
        
        
        NSLog("123\(self.navigationController)string")

        //self.prepareForSegue(<#segue: UIStoryboardSegue#>, sender: <#AnyObject?#>)
    
        
        println("row \(indexPath.row)selected")
        
    }
///////   d 
    
    
    /*
    override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject!) {
        if segue.identifier == "showDetail" {
          if let indexPath = self.tableView.indexPathForSelectedRow()
            {
               // let val : NSMutableArray = (dataArr.objectAtIndex(indexPath.row) as? NSMutableArray)!
               
                //(segue.destinationViewController as!  AllCourseDetail)
               // (segue.destinationViewController as JieDetailViewController).detailItem = val
            }
        }


    }
  
    */
    
    
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    

}
